/**
 * 金额汇总
 * 
 * @param {模板属性} props 
 * @param {模板1区域编码} card_head 
 * @param {模板1需要汇总的金额字段名} head_keys 
 * @param {模板2区域编码} card_body 
 * @param {模板2需要汇总的金额字段名} body_keys 
 * @returns 汇总金额
 */
export function calcTotal(props, card_head, head_keys, card_body, body_keys){

    let total = 0;

    let rowcount = props.cardTable.getNumberOfRows(card_body);

    if(head_keys.length > 0){

        head_keys.map((head_key) => {
            let temp = props.form.getFormItemsValue(card_head, head_key).value;

            if(temp != '' && temp != null){
                total = total + parseFloat(temp);
            }

        })
    }

    if(body_keys.length > 0 && rowcount > 0){

        body_keys.map((body_key) => {
            for(let index = 0; index < rowcount; index ++){
                let temp = props.cardTable.getValByKeyAndIndex(card_body, index, body_key).value;

                if(temp != '' && temp != null){
                    total = total + parseFloat(temp);
                }
            }
            
        })
    }

    return total;
}